package com.utc.fjc.command.saveas;

import java.awt.Frame;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.ArrayList;

import com.teamcenter.rac.commands.newalternateid.AdditionalIdInfoPanel;
import com.teamcenter.rac.commands.newalternateid.AdditionalRevInfoPanel;
import com.teamcenter.rac.commands.newitem.AssignProjectPanel;
import com.teamcenter.rac.commands.newitem.ItemMasterFormPanel;
import com.teamcenter.rac.commands.newitem.ItemRevMasterFormPanel;
import com.teamcenter.rac.commands.newitem.NewItemFinishPanel;
import com.teamcenter.rac.commands.newitem.OpenOptionPanel;
import com.teamcenter.rac.commands.saveas.SaveAsAlternateIdInfoPanel;
import com.teamcenter.rac.commands.saveas.SaveAsItemRevAttachmentPanel;
import com.teamcenter.rac.commands.saveas.SaveAsItemRevDialog;
import com.teamcenter.rac.commands.saveas.SaveAsItemRevPanel;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.Utilities;
import com.teamcenter.rac.util.log.Debug;
import com.teamcenter.rac.util.wizard.WizardControlLabel;

public class FJCSaveAsItemRevPanel extends SaveAsItemRevPanel {

	private static final long serialVersionUID = -2257086130675797070L;

	public FJCSaveAsItemRevPanel(Frame frame, TCSession tcsession,
			SaveAsItemRevDialog saveasitemrevdialog) {
		super(frame, tcsession, saveasitemrevdialog);
	}

	public FJCSaveAsItemRevPanel(Frame frame, TCSession s,
			SaveAsItemRevDialog dlg, String curCommand) {
		super(frame, s, dlg);
	}

	public FJCSaveAsItemRevPanel(Frame frame, TCSession s,
			SaveAsItemRevDialog dlg, Boolean theCloseOnFinish) {
		super(frame, s, dlg, theCloseOnFinish);
	}

	public void loadPanels() {
		if (Debug.isOn("NewItem"))
			System.out.println("SaveAsItemRevPanel::loadPanels()");
		if (this.stepPanels == null)
			this.stepPanels = new ArrayList();
		this.selectedItemType = ((SaveAsItemRevDialog) this.dialog).selectedItemType;
		this.itemInfoPanel = new FJCSaveAsItemInfoPanel(this.parentFrame,
				this.session, this);
		this.stepPanels.add(this.itemInfoPanel);
		this.itemMasterPanel = new ItemMasterFormPanel(this.parentFrame,
				this.session, this);
		this.stepPanels.add(this.itemMasterPanel);
		this.itemRevMasterPanel = new ItemRevMasterFormPanel(this.parentFrame,
				this.session, this);
		this.stepPanels.add(this.itemRevMasterPanel);
		this.altIdInfoPanel = new SaveAsAlternateIdInfoPanel(this.parentFrame,
				this.session, this);
		this.stepPanels.add(this.altIdInfoPanel);
		this.additionalAltIdInfoPanel = new AdditionalIdInfoPanel(
				this.parentFrame, this.session, this);
		this.stepPanels.add(this.additionalAltIdInfoPanel);
		this.additionalAltRevInfoPanel = new AdditionalRevInfoPanel(
				this.parentFrame, this.session, this);
		this.stepPanels.add(this.additionalAltRevInfoPanel);
		this.attachmentPanel = new SaveAsItemRevAttachmentPanel(
				this.parentFrame, this.session, this);
		this.stepPanels.add(this.attachmentPanel);
		this.assignProjectPanel = new AssignProjectPanel(this.parentFrame,
				this.session, this);
		this.stepPanels.add(this.assignProjectPanel);
		this.openOptionPanel = new OpenOptionPanel(this.parentFrame,
				this.session, this);
		try {
			Utilities.invokeMethod(this.assignProjectPanel.projSelPanel,
					"setSource", new Class[] { TCComponent.class },
					this.pasteTargets);
			Utilities.invokeMethod(this.assignProjectPanel.projSelPanel,
					"loadProjects", new Object[0]);
		} catch (Exception localException) {
		}
		this.stepPanels.add(this.openOptionPanel);
		this.finishPanel = new NewItemFinishPanel(this.parentFrame,
				this.session, this);
		this.altIdInfoPanel.typeComboBox.addItemListener(new ItemListener() {
			public void itemStateChanged(ItemEvent paramItemEvent) {
				String str = FJCSaveAsItemRevPanel.this.getIdType();
				try {
					FJCSaveAsItemRevPanel.this.additionalIdInfo = ((AdditionalIdInfoPanel) FJCSaveAsItemRevPanel.this.stepPanels
							.get(FJCSaveAsItemRevPanel.this
									.getAdditionalAltIdInfoStep()))
							.isThereAdditionalIdInfo(str);
					boolean bool = ((AdditionalIdInfoPanel) FJCSaveAsItemRevPanel.this.stepPanels
							.get(FJCSaveAsItemRevPanel.this
									.getAdditionalAltIdInfoStep()))
							.isRequired();
					if (FJCSaveAsItemRevPanel.this
							.getControlLabel(FJCSaveAsItemRevPanel.this
									.getAdditionalAltIdInfoStep()) != null)
						((WizardControlLabel) FJCSaveAsItemRevPanel.this.controlLabels
								.get(FJCSaveAsItemRevPanel.this
										.getAdditionalAltIdInfoStep()))
								.setRequired(bool);
					FJCSaveAsItemRevPanel.this.additionalRevInfo = ((AdditionalRevInfoPanel) FJCSaveAsItemRevPanel.this.stepPanels
							.get(FJCSaveAsItemRevPanel.this
									.getAdditionalAltRevInfoStep()))
							.isThereAdditionalRevInfo(str + "Rev");
					bool = ((AdditionalRevInfoPanel) FJCSaveAsItemRevPanel.this.stepPanels
							.get(FJCSaveAsItemRevPanel.this
									.getAdditionalAltRevInfoStep()))
							.isRequired();
					if (FJCSaveAsItemRevPanel.this
							.getControlLabel(FJCSaveAsItemRevPanel.this
									.getAdditionalAltRevInfoStep()) != null)
						((WizardControlLabel) FJCSaveAsItemRevPanel.this.controlLabels
								.get(FJCSaveAsItemRevPanel.this
										.getAdditionalAltRevInfoStep()))
								.setRequired(bool);
				} catch (Exception localException) {
				}
			}
		});
	}
}
